import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

import axios from './plugins/axios'
Vue.use(axios)

import Vant from 'vant';
import 'vant/lib/index.less';

Vue.use(Vant);

// import './plugins/mock.js'

import '@/assets/tw.css'

Vue.prototype.$sys = store.state.sys
Vue.mixin({
  computed: {
    $loading () {
      return store.state.loading > 0
    }
  }
})


const Pusher = window.Pusher
const WebsocketUrl = process.env.VUE_APP_WEBSOCKET_URL
const WebsocketPort = process.env.VUE_APP_WEBSOCKET_PORT
const WebsocketKey = process.env.VUE_APP_WEBSOCKET_KEY
Pusher.logToConsole = true

const pusher = new Pusher(WebsocketKey, {
  wsHost: WebsocketUrl,
  wsPort: WebsocketPort,
  forceTLS: false,
  disableStats: true,
})

pusher.connection.bind('connected', function () {
  sessionStorage.setItem('socket-id', pusher.connection.socket_id)
})
const channel = pusher.subscribe('member-channel')
Vue.prototype.$channel = channel

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount('#app')